
//datepicker plugin
//link
    $('.date-picker').datepicker({
    autoclose: true,
    todayHighlight: true
})
//show datepicker when clicking on the icon
    .next().on(ace.click_event, function(){
    $(this).prev().focus();
});

//or change it into a date range picker
$('.input-daterange').datepicker({autoclose:true});


//to translate the daterange picker, please copy the "examples/daterange-fr.js" contents here before initialization
$('input[name=date-range-picker]').daterangepicker({
    'applyClass' : 'btn-sm btn-success',
    'cancelClass' : 'btn-sm btn-default',
    locale: {
        applyLabel: 'Apply',
        cancelLabel: 'Cancel',
    }
})
    .prev().on(ace.click_event, function(){
    $(this).next().focus();
});


$('#timepicker1').timepicker({
    minuteStep: 1,
    showSeconds: true,
    showMeridian: false,
    disableFocus: true,
    icons: {
        up: 'fa fa-chevron-up',
        down: 'fa fa-chevron-down'
    }
}).on('focus', function() {
    $('#timepicker1').timepicker('showWidget');
}).next().on(ace.click_event, function(){
    $(this).prev().focus();
});




if(!ace.vars['old_ie']) $('#date-timepicker1').datetimepicker({
    //format: 'MM/DD/YYYY h:mm:ss A',//use this option to display seconds
    icons: {
        time: 'fa fa-clock-o',
        date: 'fa fa-calendar',
        up: 'fa fa-chevron-up',
        down: 'fa fa-chevron-down',
        previous: 'fa fa-chevron-left',
        next: 'fa fa-chevron-right',
        today: 'fa fa-arrows ',
        clear: 'fa fa-trash',
        close: 'fa fa-times'
    }
}).next().on(ace.click_event, function(){
    $(this).prev().focus();
});


$('#colorpicker1').colorpicker();
//$('.colorpicker').last().css('z-index', 2000);//if colorpicker is inside a modal, its z-index should be higher than modal'safe

$('#simple-colorpicker-1').ace_colorpicker();
//$('#simple-colorpicker-1').ace_colorpicker('pick', 2);//select 2nd color
//$('#simple-colorpicker-1').ace_colorpicker('pick', '#fbe983');//select #fbe983 color
//var picker = $('#simple-colorpicker-1').data('ace_colorpicker')
//picker.pick('red', true);//insert the color if it doesn't exist


$(".knob").knob();


var tag_input = $('#form-field-tags');
try {
    tag_input.tag(
        {
            placeholder: tag_input.attr('placeholder'),
            //enable typeahead by specifying the source array
            source: ace.vars['US_STATES'],//defined in ace.js >> ace.enable_search_ahead
            /**
             //or fetch data from database, fetch those that match "query"
             source: function(query, process) {
                          $.ajax({url: 'remote_source.php?q='+encodeURIComponent(query)})
                          .done(function(result_items){
                            process(result_items);
                          });
                        }
             */
        }
    )
    //programmatically add/remove a tag
    var $tag_obj = $('#form-field-tags').data('tag');
    $tag_obj.add('Programmatically Added');

    var index = $tag_obj.inValues('some tag');
    $tag_obj.remove(index);
}
catch(e) {
    //display a textarea for old IE, because it doesn't support this plugin or another one I tried!
    tag_input.after('<textarea id="'+tag_input.attr('id')+'" name="'+tag_input.attr('name')+'" rows="3">'+tag_input.val()+'</textarea>').remove();
    //autosize($('#form-field-tags'));
}



